﻿
@{
    ViewBag.Title = "过站详情";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}

<div id="page"></div>

<script type="text/template" id="tplPage">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" v-html="lang.Field.ViaSiteCondition">过站情况：</label>
                        <div class="layui-input-inline">
                            <select id="selViaSite">
                                <option value="0">未过站</option>
                                <option value="1">已过站</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button id="btnSearch" class="layui-btn layuiadmin-btn-list" type="button">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                        <a id="btnExport" class="layui-btn layui-btn-normal layuiadmin-btn-list" target="_blank" href="javascript:void(0)">
                            <i class="layui-icon layui-icon-download-circle layuiadmin-button-btn"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-card">
            <div class="layui-card-body">
                <table id="table" lay-filter="table"></table>
            </div>
        </div>
    </div>
</script>

@section Scripts{
    <script src="/res/echarts/echarts.min.js"></script>
    <script src="/res/echarts/macarons.js"></script>
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package
            }
        });
        setTimeout(function () {
            initLayui();
        }, 50);

        function initLayui() {
            layui.use(['table', 'layer', 'form', 'laydate', 'element'], function () {
                var layer = layui.layer,
                    table = layui.table,
                    form = layui.form,
                    laydate = layui.laydate;

                var paras = JSON.parse(decodeURIComponent(getParameter("paras")));
                paras.hasViaSite = $("#selViaSite").val() == "1";
                var options = {
                    elem: '#table'
                    , url: '/Report/QueryViaSiteAnalyseDetails'
                    , method: "post"
                    , where: paras
                    , page: {
                        limit: 15
                        , limits: [15, 20, 25, 30, 40, 50]
                    }
                    , response: {
                        statusName: 'ErrCode'
                        , statusCode: 200
                        , msgName: 'ErrCode'
                        , countName: 'TotalCount'
                        , dataName: 'Data'
                    }
                    , cols: [[
                        { title: '序号', type: "numbers", width: 60, fixed: "left" }
                        , { field: 'BarCode', title: '组件条码', minWidth: 200, fixed: "left" }
                        , { field: 'OrderNo', title: '订单号', minWidth: 150 }
                        , { field: 'WorkOrderNo', title: '工单号', minWidth: 200 }
                        , { field: 'ProductCode', title: '成品料号', minWidth: 150 }
                        , { field: 'ProductName', title: '成品名称', minWidth: 250 }
                        , { field: 'WorkshopName', title: '生产车间', minWidth: 150 }
                        , {
                            title: '最终站点', minWidth: 150, templet: function (d) {
                                return d.CNLastSite != "" ? d.CNLastSite : (d.DistributeTime != null ? "分片" : "");
                            }
                        }

                        , { field: 'DistributeTimeStr', title: '分片时间', minWidth: 150 }
                        , { field: 'WeldingTimeStr', title: '焊接时间', minWidth: 150 }
                        , { field: 'LaminatedTimeStr', title: '叠层时间', minWidth: 150 }
                        , { field: 'EL1TimeStr', title: 'EL1时间', minWidth: 150 }
                        , { field: 'TopTimeStr', title: '层压时间', minWidth: 150 }
                        , { field: 'NQCTimeStr', title: 'NQC时间', minWidth: 150 }
                        , { field: 'FramingTimeStr', title: '装框时间', minWidth: 150 }
                        , { field: 'CleanTimeStr', title: '清洗时间', minWidth: 150 }
                        , { field: 'IVTestTimeStr', title: 'IV时间', minWidth: 150 }
                        , { field: 'InsulatedResistanceTimeStr', title: '绝缘耐压时间', minWidth: 150 }
                        , { field: 'EL2TimeStr', title: 'EL2时间', minWidth: 150 }
                        , { field: 'NameplatePrintingTimeStr', title: '铭牌打印时间', minWidth: 150 }
                        , { field: 'FinalInspectionTimeStr', title: '终检时间', minWidth: 150 }
                        , { field: 'PackTimeStr', title: '打包时间', minWidth: 150 }
                        , { field: 'InboundTimeStr', title: '入库时间', minWidth: 150 }
                    ]]
                };

                $("#btnSearch").click(function () {
                    queryTable();
                });
                queryTable();
                function queryTable() {
                    options.page.curr = 1;
                    options.where.hasViaSite = $("#selViaSite").val() == "1";

                    var parasArray = new Array();
                    for (var key in options.where) {
                        parasArray.push(key + "=" + options.where[key]);
                    }
                    $("#btnExport").attr("href", "/Report/ExportViaSiteAnalyseDetails?" + parasArray.join("&"));

                    if (table.index <= 0) {
                        table.render(options);
                    } else {
                        table.reload("table", options);
                    }
                }
            });
        }
    </script>
}
